#!/usr/bin/env bash
set -eux
for emulator in --qemu --gem5; do
  # Userland.
  # TODO make work.
  #./run --arch x86_64 --background --userland add "$emulator" --wait-gdb &
  #./run-gdb --arch x86_64 --userland add "$emulator" --test "$@"
  #wait

  # Baremetal.
  ./run --arch arm --background --baremetal add "$emulator" --wait-gdb &
  ./run-gdb --arch arm --baremetal add "$emulator" --test "$@"
  wait
  ./run --arch arm --background --baremetal arch/arm/add "$emulator" --wait-gdb &
  ./run-gdb --arch arm --baremetal arch/arm/add "$emulator" --test "$@"
  wait
  ./run --arch arm --background --baremetal arch/arm/regs "$emulator" --wait-gdb &
  ./run-gdb --arch arm --baremetal arch/arm/regs "$emulator" --test "$@"
  wait
  ./run --arch aarch64 --background --baremetal add "$emulator" --wait-gdb &
  ./run-gdb --arch aarch64 --baremetal add "$emulator" --test "$@"
  wait
  ./run --arch aarch64 --background --baremetal arch/aarch64/add "$emulator" --wait-gdb &
  ./run-gdb --arch aarch64 --baremetal arch/aarch64/add "$emulator" --test "$@"
  wait
  ./run --arch aarch64 --background --baremetal arch/aarch64/regs "$emulator" --wait-gdb &
  ./run-gdb --arch aarch64 --baremetal arch/aarch64/regs "$emulator" --test "$@"
  wait
  ./run --arch aarch64 --background --baremetal arch/aarch64/fadd "$emulator" --wait-gdb &
  ./run-gdb --arch aarch64 --baremetal arch/aarch64/fadd "$emulator" --test "$@"
  wait
  ./run --arch aarch64 --background --baremetal arch/aarch64/regs "$emulator" --wait-gdb &
  ./run-gdb --arch aarch64 --baremetal arch/aarch64/regs "$emulator" --test "$@"
  wait
done
